window.onload = function(){
	
	if ($('#js_block_border_friend_mutual-friend').hasClass('block')) {		
		$( "#column-left" ).addClass('isRight');
	}else{		
		$( "#column-left" ).addClass('notRight');	
	}	
}

function ChangConfirm(){
	
	if(confirm(getPhrase('core.are_you_sure'))){ 
		return true;
	}
	else{ 
		return false;
	} 	
}

$Behavior.customNebula = function(){
	
	$('#nb_features_link').click(function(){
		
		if ($(this).hasClass('nb_is_clicked')){
			$(this).removeClass('nb_is_clicked');
			$('#nb_features_holder').slideUp('fast');
		}else{
			$(this).addClass('nb_is_clicked');
			$('#nb_features_holder').slideDown('fast');
		}
		
		return false;
	});
	
	$('.js_view_more_features').click(function(){
		
		if ($(this).attr('rel') == 'more'){
			$('#nb_main_menu ul li').each(function(){
				if ($(this).is(':hidden') && !$(this).hasClass('is_force_hidden')){
					$(this).show().addClass('was_hidden');
				}
			});
			$(this).hide();
			$('.js_view_less').show();
		}else{
			$('#nb_main_menu ul li.was_hidden').hide();
			$(this).hide();
			$('.js_view_more').show();			
		}
		
		
		return false;
	});	
	
	$('.nb_edit_block_title').click(function(){
		
		$('#nb_main_menu ul li').each(function(){
			if ($(this).is(':hidden') && !$(this).hasClass('is_force_hidden')){
				$(this).show().addClass('was_hidden');							
			}
			
			if ($(this).hasClass('is_force_hidden')){
				$(this).find('a:first').append('<span class="nb_menu_add">Add</span>');
			}else{
				$(this).find('a:first').append('<span class="nb_menu_remove">Delete</span>');	
			}
			
			$(this).addClass('is_edit_mode');
			
		});		
		
		$('.js_done_edit_mode').show();
		$('.js_view_more_features').hide();
		$('.js_add_more_menus').show().click(function(){
			$('.is_force_hidden').show();
			return false;
		});
		
		$('.is_edit_mode a').click(function(){			
			return false;
		});
		
		$('.nb_menu_remove').click(function(){
			
			$.ajaxCall('theme.deleteMenu', 'id=' + $(this).parents('li:first').attr('rel').replace('menu', ''), 'GET');
			$(this).parents('li:first').remove();
			
			return false;
		});	

		$('.nb_menu_add').click(function(){
			
			$.ajaxCall('theme.deleteMenu', 'add=true&id=' + $(this).parents('li:first').attr('rel').replace('menu', ''), 'GET');
			$(this).parents('li:first').removeClass('is_force_hidden');
			
			return false;
		});			
		
		return false;
	});
	
	$('.js_done_edit_mode').click(function(){

		$(this).hide();
		$('.js_done_edit_mode').hide();
		$('.js_view_more_features').hide();
		$('.js_add_more_menus').hide();		
		$('.js_view_more').show();
		$('#nb_main_menu ul li.was_hidden').hide();
		$('#nb_main_menu ul li.is_force_hidden').hide();
		$('.nb_menu_remove').remove();
		$('.nb_menu_add').remove();
		$('.is_edit_mode a').click(function(){
			window.location.href = $(this).attr('href');
			return true;
		});		
		$('#nb_main_menu li').removeClass('is_edit_mode');
		
		return false;
	});
	
	$('.js_comment_feed_textarea').focus(function(){
		$(this).parents('.comment_mini:first').find('.button_set_off:first').removeClass('button_set_off');
	});
	
	fixHeightForFooter();
	/* Ads still broke the layout for me*/
	setTimeout(fixHeightForFooter, 1000);
	
	
	$('.photo a').click(function(){
		$('#global_attachment_status').css('display','block');
	});
	
	$('.status a').click(function(){
		$('.activity_feed_form_button_status_info').css('display','block');
		$('#global_attachment_photo').css('display','block');		
	});
	
	$('#activity_feed_textarea_status_info').click(function(){
		if($('#global_attachment_photo_file_input').val()==''){
			alert($('#activity_feed_textarea_status_info_hidden_text').val());
		}		
					
	});
	
	$('#activity_feed_textarea_status_info').keypress(function(){
		if($('#global_attachment_photo_file_input').val()==''){
			alert($('#activity_feed_textarea_status_info_hidden_text').val());
		}		
						
	});
	
	
	$('#global_attachment_photo_file_input').click(function(){
		$('.activity_feed_form_attach .photo a').trigger('click');	
		$('#js_new_feed_comment').css('display','none');
		$('#activity_feed_textarea_status_info').val('');	
		
	});
	
	$('#userstatus textarea').click(function(){
		$('.activity_feed_form_attach .status a').trigger('click');	
		$('#js_new_feed_comment').css('display','block');
		//$('#userstatus textarea').val();	
	});
			
	$('.privacy_setting_holder a[rel=2]').hide();
	$('.privacy_setting_holder a[rel=4]').hide();
		
	$('#activity_feed_submit_left').click(function(){
		$('#activity_feed_submit').trigger('click');	
	});
	
	/*var theValue = "15";
	$("#js_mp_id_0").val(theValue).prop('selected',true);*/
		
//	$('.js_feed_view_more_entry_holder a.userstatus').click(function(){
//		$('.js_feed_view_more_entry_holder .comment_mini_content_holder').css('display','none');
//		$('#framepopup').attr('src',$(this).attr('href')+'&popup=1');		
//		$( "#dialog" ).dialog( "open" );		
//	});
	
	$('.js_listing_parent a.marketplace').click(function(){
		$('.js_listing_parent .comment_mini_content_holder').css('display','none');
		$('#framepopup').attr('src',$(this).attr('href')+'&popup=1');		
		$( "#dialog" ).dialog( "open" );
		return false;		
	});
	
/*	$('.js_feed_view_more_entry_holder a.js_feed_entry_add_comment').click(function(){
		$('.js_feed_view_more_entry_holder .comment_mini_content_holder').css('display','none');
		$('.'+$(this).attr('id')).trigger('click');	
		
	});*/
	
	$( "#dialog_trigger" ).click(function() {
		$( "#dialog" ).dialog( "open" );	
	});
	
	$( ".ui-dialog-titlebar-close" ).click(function() {
		$('#framepopup').attr('src','');
		$( "#dialog" ).dialog( "close" );			
	});
	
	$("#dialog").dialog({
		autoOpen: false,
		position: 'center' ,
		title: $("#commenttext").text(),
		draggable: false,
		width : 1020,
		height : 500, 
		resizable : true,
		modal : true,
	});
	
	$( ".li-comment a" ).click(function() {
		$('a.'+$(this).attr('id')).trigger('click');			
	});
	
};

function fixHeightForFooter()
{
	$('#main_content_padding').ready(function(){
        $('#main_content_padding').css('min-height', $('#left').height());
	});
}

function addCustomComment(f_id,comment){
	if(comment!=''){
		$('#nameavatar_'+f_id).text($('#header_menu_user_profile a').text());
		$('#nameavatar_'+f_id).attr('href',$('#header_menu_user_profile a').attr('href'));
		$('#linkavatar_'+f_id).attr('href',$('#header_menu_user_profile a').attr('href'));
		$('#imageavatar_'+f_id).attr('src',$('#header_menu_user_image img').attr('src'));
		
		$('#js_comment_text_hidden_'+f_id).html(comment);
		$('#js_comment_hidden_'+f_id).css('display','block');
		return true;
	}
}